﻿
var connection = require("../../app_modules/dbAccess/mongoConfig.js");
var mongoose = require('mongoose');
var db = mongoose.createConnection(connection.getConnectionString("")); //连接test数据库
//var db = mongoose.Connection(connection.getConnectionString(""));

var Schema = mongoose.Schema; //创建模型【骨架模板】
var messageSchema = new Schema({
    name: String,
    email: String,
	telphone:String,
    qq: String,
    weixin: String,
    leaveMsg: String,
    createDate: Date,
    flag:String,//0未读、1：已读
});

messageSchema.methods.add = function (message, callback) {
    this.name = message.name;
    this.email = message.email;
	this.telphone = message.telphone;
    this.qq = message.qq;
    this.weixin = message.weixin;
    this.leaveMsg = message.leaveMsg;
    this.createDate = message.createDate;
    this.flag = message.flag;
    this.save(callback);
}
var message = db.model('massages', messageSchema);
module.exports = message;
